function compose(...funcs) {
  if (funcs.length === 0) {
    return arg => arg
  }

  if (funcs.length === 1) {
    return funcs[0]
  }

  return funcs.reduce((a, b) => (...args) => a(b(...args)))
}

const f1 = value => value + 1
const f2 = value => value * 2
const f3 = value => value - 3
const value = compose(f1, f2, f3)(2)
console.log(value)  // (2-3)*2+1=-1